package com.example.educationalsystem.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.educationalsystem.entity.Vo.CourseVo;
import com.example.educationalsystem.entity.Vo.SelectCourseVo;
import com.example.educationalsystem.entity.Vo.VoteVo;
import com.example.educationalsystem.entity.Vote;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zpc
 * @since 2022-12-02
 */
@Repository
public interface IVoteMapper extends BaseMapper<Vote> {

    @Select("<script>" +
            "select a.*,c.teacher_name,c.teacher_sex,c.teacher_phone \n" +
            "from vote a  \n" +
            "left join teacher c on a.teacher_id=c.teacher_id \n" +
            "</script>")
    List<VoteVo> getAllVote();

    @Select("<script>" +
            "select a.*,c.teacher_name,c.teacher_sex,c.teacher_phone \n" +
            "from vote a  \n" +
            "left join teacher c on a.teacher_id=c.teacher_id \n" +
            "<if test='ew != null'>" +
            " AND ${ew.SqlSegment}" +
            "</if>"
            + "</script>")
    Page<VoteVo> getVotePage(Page<VoteVo> page, @Param("ew") Wrapper wrapper);
}
